const mysql = require('mysql')

// 创建连接对象

const con = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'123321',
    port:'3306',
    // 数据库
    database:'myblog'
})

// 连接
con.connect()

// 执行sql语句
const sql ="select * from users"
// const sql = "INSERT INTO users(username,`password`,realname)value('liuwu','123','刘五');"
con.query(sql,(err,result) => {
    if(err){
        console.log(err)
        return
    }
    console.log(result)
})

// 关闭连接
con.end()